import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../pages/Home";
import Tong from "../pages/Tong";
// import Find from "../pages/Find";
import Mine from "../pages/Mine";
import Login from "../pages/Login";
import Cart from "../pages/Cart";
import Detail from "../pages/Detail";
import Search from "../pages/Search";
import Reg from "../pages/Reg";
import ModifyPWD from "../pages/ModifyPWD";
import ModifyInfo from "../pages/ModifyInfo";
import Receiving from "../pages/Receiving";

Vue.use(VueRouter);

const store = new VueRouter({
  mode: 'hash',
    routes: [
      { path: "/", redirect: "/home" },
      {
        path: "/login",
        component: Login,
        name:'Login',
        meta: {
          showFooter: false, //有些页面不需要底部导航，有些页面必须有底部导航
        },
      },
      {
        path: "/reg",
        component: Reg,
        name:'Reg',
        meta: {
          showFooter: false, //有些页面不需要底部导航，有些页面必须有底部导航
        },
      },
      {
        path: "/home",
        component: Home,
        name:'Home',
        meta: {
          showFooter: true,
        },
      },
      {
        path: "/tong",
        component: Tong,
        //路由独享守卫
        // beforeEnter: (to, from, next) => {
        //   const isLogined = localStorage.getItem("token") || "";
        //   if (!isLogined) {
        //     next("/login");
        //   } else {
        //     next(); //放行本页面
        //   }
        // },
        meta: {
          showFooter: true,
        },
      },
      // {
      //   path: "/find",
      //   component: Find,
      //   meta: {
      //     showFooter: true,
      //   },
      // },
      {
        path: "/search",
        component: Search,
        name:'Search',
        meta: {
          showFooter: true,
        },
      },
      {
        path: "/cart",
        component: Cart,
        name:'Cart',
        meta: {
          showFooter: true,
        },
      },
      {
        path: "/detail",
        component: Detail,
        meta: {
          showFooter: false,
        },
      },
      {
        path: "/receiving",
        component: Receiving,
        name:'Receiving',
        meta: {
          showFooter: false,
        },
      },
      {
        path: "/modifyPWD",
        component: ModifyPWD,
        name: 'ModifyPWD',
        meta: {
          showFooter: false,
        },
      },
      {
        path: "/modifyInfo",
        component: ModifyInfo,
        name: 'ModifyInfo',
        meta: {
          showFooter: false,
        },
      },
      {
        path: "/mine",
        component: Mine,
        name:'Mine',
        meta: {
          showFooter: false,
        },
      },
    ],
    linkActiveClass: "myactive",
  });
  
  export default store;